<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="skladiscenje.*"%>
<%@ page import="java.util.ArrayList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>SKLADISCENJE systems</title>
        <LINK href="CSS/style.css" rel="stylesheet" type="text/css" />
        <LINK href="CSS/menu.css" rel="stylesheet" type="text/css" />
        <LINK REL="SHORTCUT ICON" HREF="images/favicon.ico" />
        <script type="text/javascript">
		function potrditvenoOkno(){
			var blagoID = document.getElementById("dropdownBlago").value;
			var dodatnaKolicina = document.getElementById("dodatnaKolicina").value;
			window.open("potrditvenoOkno.jsp?dropdownBlago=" + blagoID + "&dodatnaKolicina=" + dodatnaKolicina + "&porociloO=izdaji&potrdi=Potrdi","Izdaja blaga","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=400, height=400");
		}
		</script>
    </head>
        
    <body>
		<table id="wrapper">
			<tr>
				<td>
					<% 
					if (session.getAttribute("uporabnik") != null) {
						Uporabnik uporabnik = (Uporabnik) session.getAttribute("uporabnik");
					%>
                	<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td>
                        		<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  	<tr>
                                    	<td class="head_top"></td>
                                  	</tr>
                                  	<tr>
                                    	<td>
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                               	  	<td class="head_middle"></td>
                                                	<td class="logout_bg"><%= uporabnik.getUporabniskoIme() %></td>
                                                	<td class="logout_logo"><a href="odjava.jsp"><img src="images/logout_logo.png" alt="logout" width="34" height="28" border="0"></a></td>
                                                	<td class="logout_right"></td>
                                             	</tr>
                                            </table>
                                        </td>
                                 	</tr>
                                  	<tr>
                                  	  	<td class="head_bottom"></td>
                                  	</tr>
                                  	<tr>
                                    	<td>
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                               	  	<td class="menu_left"></td>
                                                	<td class="menu_bg"><%@ include file="meni.jsp" %></td>
                                                	<td class="menu_right"></td>
                                             	</tr>
                                            </table>
                                        </td>
                                  	</tr>
                                  	<tr>
                                    	<td class="menu_bottom"></td>
                                  	</tr>
                                </table>
							</td>
                      	</tr>
                      	<tr>
                        	<td>
                            	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  	<tr>
                                      	<td class="left"></td>
                                      	<td valign="top" bgcolor="#E7F6FF">
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                                	<td>
                                                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                          	<tr>
                                                           	  	<td class="main_left"></td>
                                                            	<td bgcolor="#FFFFFF" align="center">
	                                                            	<table class="izpisTabela" cellspacing="0">
	                                                                	<tr><td colspan="3" class="naslov">- IZDAJA BLAGA -</td></tr>
	                                                                    <tr>
	                                                                    	<th>Blago</th>
	                                                                        <th>Izdana količina</th>
	                                                                        <th></th>
	                                                                    </tr>
	                                                                    <tr>
	                                                                    	<td>
	                                                                        	<select name="dropdownBlago" id="dropdownBlago">
	                                                                            <%
			                                                        			ArrayList<Blago> seznamBlaga;
			                                                        			
			                                                        			if(uporabnik.getSektor() == 0)
			                                                        				seznamBlaga = Evidenca.izpisiVsoBlago();
			                                                        			else
			                                                        				seznamBlaga = Evidenca.izpisiVsoBlagoBySektor(uporabnik.getSektor());
			                                                        			
			                                                        			if(seznamBlaga.size() < 1){
			                                                        				%>
			                                                        				<option value="">Prazno skladišče</option>
			                                                        				<%
			                                                        			}else{
			                                                        				int tabela;
			                                                        				for(int i = 0; i < seznamBlaga.size(); i++){
			                                                        					if(i%2 == 0)
			                                                        						tabela = 2;
			                                                        					else
			                                                        						tabela = 1;
			                                                        					%>
			                                                        					<option value="<%= seznamBlaga.get(i).getID() %>">Kolicina: <%= seznamBlaga.get(i).getKolicina() %>, Sektor: <%= seznamBlaga.get(i).getSektor() %>, Ime: <%= seznamBlaga.get(i).getIme() %></option>						                                                            			
			                                                        					<%
			                                                        				}
			                                                        			}
			                                                        			%>
	                                                                            </select>
	                                                                        </td>
	                                                                        <td><input name="dodatnaKolicina" type="text" id="dodatnaKolicina" /></td>
	                                                                        <td><input name="potrdi" type="submit" value="Potrdi" onClick="potrditvenoOkno()" /></td>
	                                                                    </tr>
	                                                                </table>
																</td>
                                                            	<td class="main_right"></td>
                                                          	</tr>
                                                        </table>
                                                    </td>
                                              	</tr>
                                              	<tr>
                                                	<td class="main_bottom"></td>
                                              	</tr>
                                            </table>
                                        </td>
                                        <td width="184" valign="top" bgcolor="#E7F6FF">
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                                	<td>
                                                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                          	<tr>
                                                           	  	<td class="side_left"></td>
                                                            	<td bgcolor="#FFFFFF"><%@ include file="statistika.jsp" %></td>
                                                            	<td class="side_right"></td>
                                                          	</tr>
                                                        </table>
                                                    </td>
                                              	</tr>
                                              	<tr>
                                                	<td class="side_bottom"></td>
                                              	</tr>
                                            </table>
                                        </td>
                                        <td class="right"></td>
                                  	</tr>
                                </table>
                            </td>
                      	</tr>
                      	<tr>
                        	<td class="footer"></td>
                      	</tr>
                    </table>
                    <%}else{response.sendRedirect("index.jsp?prijava=potrebna");}%>
                </td>
			</tr>
		</table>
	</body>
</html>
